<?php
class TuVungModel extends AppModel{

    public $name = 'TuVungModel';
    public $useTable = 'tuvung';
    public $primaryKey = 'id';
	
	public function layDanhSachTuVungTheoDieuKien($thamsoForm = array())
	{
		$conditions = array(
				'loai_tu' 	=> $thamsoForm['loaiTu'],
				'bai_hoc' 	=> $thamsoForm['baiHoc'],
				'da_xoa'	=> 0
			);
		if (!empty($thamsoForm['nhomTu'])) $conditions['nhom_tu'] = $thamsoForm['nhomTu'] ;
		return $this->find('all', array(
			'conditions'=> $conditions,
			'fields'	=> array(
				'tu_vung',
				'nghia_tu',
				'ghi_chu'
			),
			'order'		=> 'rand()'
		));
	}
	
} 